package com.ruoyi.wechat.api;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.wechat.domain.Campsite;
import com.ruoyi.wechat.domain.FacilityType;
import com.ruoyi.wechat.service.ICampsiteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "微信小程序API-营地营位管理",tags={"微信小程序API-营地营位管理"})
@RestController
@RequestMapping("/wechat/campsite")
public class WxCampsiteController extends BaseController {
    @Autowired
    private ICampsiteService campsiteService;
  @ApiOperation(value = "按条件搜索营位列表",response = Campsite.class)
    @GetMapping("/wxlist")
  public AjaxResult list(Campsite campsite)
  {

      List<Campsite> list=campsiteService.selectCampsiteList(campsite);
      return success(list);
  }

    @ApiOperation(value = "新增营地营位")
    @GetMapping("/wxadd")
    public AjaxResult add(@RequestBody Campsite campsites)
    {
        return toAjax(campsiteService.insertCampsite(campsites));


    }

    @ApiOperation(value = "修改营地营位")
    @GetMapping("/wxupdate")
    public AjaxResult edit(@RequestBody Campsite campsite)
    {
        return toAjax(campsiteService.updateCampsite(campsite));


    }


    @ApiOperation(value = "删除营地营位")
    @GetMapping("/delete/{campsiteId}")
    public AjaxResult remove(@PathVariable("campsiteId") String campsiteId)
    {
        return toAjax(campsiteService.deleteCampsiteByCampsiteId(campsiteId));


    }
    @ApiOperation(value = "根据营位Id获取详情信息",response = Campsite.class)
    @ApiParam(required = true,value = "直接传入id")
    @GetMapping("/wxgetInfo/{campsiteId}")
    public AjaxResult getInfo(@PathVariable("campsiteId") String campsiteId)
    {


        return success(campsiteService.selectCampsiteByCampsiteId(campsiteId));
    }


}
